<?php
require_once ("../db/connectdatabase.php");
require_once ("../entitys/CardType.php");

function getCardTypes() {
	$con = new ConnectDB();
	
	$tbl = "cardtype";
	$fn = array('cardtypeid', 'cardtyprname', 'cardtypelogo', 'datecreate');
	$condetion = array('isusecardtype' => true);
	return $con -> getvalueorderby($tbl, $fn, $condetion, 'datecreate');
}

function getCardType($id) {
	$con = new ConnectDB();
	
	$tbl = "cardtype";
	$fn = array('cardtypeid', 'cardtyprname', 'cardtypelogo', 'datecreate');
	$condetion = array('cardtypeid' => $id);
	return $con -> getvalue($tbl, $fn, $condetion);
}

function insertCardType($cardtype) {
	$con = new ConnectDB();
	
	$tbl = "cardtype";
	$fn = array('cardtypeid' => ($cardtype -> getID()), 'cardtyprname' => ($cardtype -> getName()), 'cardtypelogo' => ($cardtype -> getLogo()), 'datecreate' => ($cardtype -> getDatecreate()));
	return $con -> insert($tbl, $fn);
}

function updateCardType($cardtype) {
	$con = new ConnectDB();
	
	$tbl = "cardtype";
	$fn = array('cardtyprname' => ($cardtype -> getName()), 'cardtypelogo' => ($cardtype -> getLogo()), 'datecreate' => ($cardtype -> getDatecreate()));
	$condition = array('cardtypeid' => ($cardtype -> getID()));
	return $con -> update($tbl, $fn, $condition);
}

function deleteCardType($id) {
	$con = new ConnectDB();
	
	$tbl = "cardtype";
	$fn = array('isusecardtype' => false);
	$condition = array('cardtypeid' => $id);
	return $con -> update($tbl, $fn, $condition);
}

?>